
package com.woniuxy.woniuhis.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.woniuxy.woniuhis.entity.Job;
import com.woniuxy.woniuhis.entity.Permission;
import com.woniuxy.woniuhis.exception.JobServiceException;
import com.woniuxy.woniuhis.mapper.JobMapper;
import com.woniuxy.woniuhis.service.JobService;

@Service
public class JobServiceImpl implements JobService {

	@Autowired
	private JobMapper jobmapper;

	@Override
	public void addJob(Job job) {
		try {
			jobmapper.insertJob(job);
		} catch (Exception e) {
			e.printStackTrace();
			throw new JobServiceException("系统维护中");
		}
	}

	@Override
	public void modifyJobInfo(Job job) {
		try {
			jobmapper.updateJobInfo(job);
		} catch (Exception e) {
			e.printStackTrace();
			throw new JobServiceException("系统维护中");
		}
	}

	@Override
	public void delJobByJobid(String jobId) {
		try {
			jobmapper.deleteJobByJobid(jobId);
		} catch (Exception e) {
			e.printStackTrace();
			throw new JobServiceException("系统维护中");
		}
	}

	@Override
	public Job findJobByjobId(String jobId) {
		try {
			return jobmapper.selectJobByjobId(jobId);
		} catch (Exception e) {
			e.printStackTrace();
			throw new JobServiceException("系统维护中");
		}
	}

	/**
	 * 	查员工的角色
	 */
	@Override
	public List<Job> findEmpJobByempId(String empId) {
		try {
			return jobmapper.selectEmpJobByempId(empId);
		} catch (Exception e) {
			e.printStackTrace();
			throw new JobServiceException("系统维护中");
		}
	}

	/**
	 * 	查角色的权限
	 */
	@Override
	public List<Permission> findRolePermission(String jobId) {
		try {
			return jobmapper.selectRolePermission(jobId);
		} catch (Exception e) {
			e.printStackTrace();
			throw new JobServiceException("系统维护中");
		}
	}

	@Override
	public List<Job> findAllJob() {
		try {
			return jobmapper.selectAllJob();
		} catch (Exception e) {
			e.printStackTrace();
			throw new JobServiceException("系统维护中");
		}
	}

}
